/**
 * @author		Sergey Suzdalskiy
 * @e-mail:		sergey.suzdalskiy@gmail.com
 */
package ua.kiev.gcore.ui.page
{
	import ua.kiev.gcore.logger.Logger;

	public class PagesManager {
		
		protected static var currentPage:IPage;
		
		public static function open_Page(page:IPage):IPage{			
			if(currentPage){
				currentPage.destroy();
				currentPage = null;
			}			
			
			currentPage = page;
			
			if(currentPage){
				currentPage.open();
			}
			
			return currentPage;
		}
		
		public static function sendToPage(UID:String, command:PageCommand):void{
			if((currentPage != null) && (UID != null)){
				currentPage.update(command);
			}
		}
		public static function sendToCurrentPage(command:PageCommand):void{
			if(currentPage != null){
				currentPage.update(command);
			}
		}
		public static function closeCurrentPage():void{
			if(currentPage){
				currentPage.destroy();
				currentPage = null;
			}	
		}
	}
}